import 'package:flutter/material.dart';
import 'package:flutter_shop/widgets/page_content.dart';

class LoginPage extends StatefulWidget {
  @override
  _LoginPageState createState() => _LoginPageState();
}

class _LoginPageState extends State<LoginPage> {
  bool showPassword = false;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('登录'),
      ),
      body: SafeArea(
        minimum: EdgeInsets.all(20),
        child: ListView(
          children: [
            TextField(
              decoration: InputDecoration(labelText: '用户名', hintText: '请输入用户名'),
            ),
            TextField(
              decoration: InputDecoration(
                  labelText: '密码',
                  hintText: '请输入密码',
                  suffixIcon: IconButton(
                    icon: Icon(
                        showPassword ? Icons.visibility_off : Icons.visibility),
                    onPressed: () {
                      setState(() {
                        showPassword = !showPassword;
                      });
                    },
                  )),
              obscureText: !showPassword,
            ),
            Padding(padding: EdgeInsets.all(10)),
            ElevatedButton(
                onPressed: () => {print('object')},
                child: Text('登录'),
                style: ButtonStyle(
                    backgroundColor: MaterialStateProperty.all(Colors.green))),
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Text('还没有账号，'),
                TextButton(
                    onPressed: () =>
                        {Navigator.pushReplacementNamed(context, 'register')},
                    child: Text(
                      '去注册',
                      style: TextStyle(color: Colors.green),
                    ))
              ],
            )
          ],
        ),
      ),
    );
  }
}
